home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / demo3.zoo / demo / misc / oclose.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-21  |  1.6 KB  |  73 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: oclose.c,v 4.2 88/06/22 14:37:55 bianchi Exp $
  9.     $Source: /tmp/mgrsrc/demo/misc/RCS/oclose.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/demo/misc/RCS/oclose.c,v $$Revision: 4.2 $";
  12.  
  13. /* close a window */
  14.  
  15. #include <signal.h>
  16. #include "term.h"
  17.  
  18. #define POS(x)        800+(x)/18        /* where to put window */
  19. #define Max(x,y)    ((x)>(y)?(x):(y))
  20.  
  21. main(argc,argv)
  22. int argc;
  23. char **argv;
  24.    {
  25.    char host[16];
  26.    char *text;
  27.    char line[2];
  28.    int x,y,wide,high;
  29.    int clean();
  30.    int font;
  31.  
  32.    /* get icon text */
  33.  
  34.    if (argc>1) 
  35.       text = argv[1];
  36.    else {
  37.       gethostname(host,sizeof(host));
  38.       text = host;
  39.       }
  40.  
  41.    m_setup(0);
  42.    m_push(P_ALL);    
  43.    signal(SIGINT,clean);
  44.    signal(SIGTERM,clean);
  45.    m_setevent(ACTIVATED,"A\\n");
  46.    m_setevent(REDRAW,"R\\n"); 
  47.  
  48.    get_size(&x,&y,&wide,&high);
  49.    if (argc>2 && (font=atoi(argv[2])) > 0)
  50.       m_font(font);
  51.    m_sizeall(x,POS(y+high/2),Max(strlen(text),5),1);
  52.    m_setmode(M_NOWRAP);
  53.    m_setmode(M_BACKGROUND);
  54.    m_clear();
  55.    m_printstr(text);
  56.    m_clearmode(M_ACTIVATE);
  57.    m_flush();
  58.  
  59.    while(1) {
  60.       read(0,line,sizeof(line));
  61.       m_clear();
  62.       m_printstr(text);
  63.       m_flush();
  64.       if (*line == 'A')
  65.          clean();
  66.       }
  67.    }
  68. clean()
  69.    {
  70.    m_pop();
  71.    exit(1);
  72.    }
  73.